<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>新闻管理编辑</title>
<link href="<%=basePath%>skin/css/validform/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/validform/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/editor/kindeditor.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/common.js"></script>
<script language="javascript">
	$().ready(function(){
		//验证
		var validform = $("#form1").Validform({
			btnSubmit:"#save",
			tiptype:3,
			beforeSubmit:function(curform){
				var newsTypeId = $("#newsTypeId").val();
				if (newsTypeId == null || newsTypeId == "") {
					alert("请选择新闻类别!");
					return false;
				}
			}
		});
		validform.addRule([
			{
			    ele:"#title",
			    datatype:"*",
			    nullmsg:"请输入标题！"
			},	                   
			{
			    ele:"#introduction",
			    datatype:"*",
			    nullmsg:"请输入介绍！"
			},		                   
			{
			    ele:"#fromwho",
			    datatype:"*",
			    nullmsg:"请输入来源！"
			},		                   
			{
			    ele:"#content",
			    datatype:"*",
			    nullmsg:"请输入内容！"
			}
		]);
	 });	
</script>
</head>

<body>
	<form id="form1" name="form1" method="post" action="<%=basePath%>admin/news/update.shtml" enctype="multipart/form-data">
	<input type="hidden" name="id" value="${news.id}" />
		<table width="98%" class="input tabContent">
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">新闻类别：</td>
				<td class="tdLeft">
					<select name="newsTypeId" id="newsTypeId" data-placeholder="请选择新闻类别">
						<option value=""></option>
						<c:forEach items="${newsTypes }" var="newsType">
							<option value="${newsType.id }" <c:if test="${not empty news.newsType && news.newsType.id == newsType.id }">selected</c:if>>${newsType.type }</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">标题：</td>
				<td class="tdLeft"><input id="title" name="title"
					size="30" class="input" value="${news.title}"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">图片：</td>
				<td class="tdLeft"><input type="file" name="file" id="file"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">介绍：</td>
				<td class="tdLeft"><textarea id="introduction" name="introduction" style="width: 100%;">${news.introduction}</textarea></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">来源：</td>
				<td class="tdLeft"><input id="fromwho" name="fromwho"
					size="30" class="input" value="${news.fromwho}"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<td class="tdRight">内容：</td>
				<td class="tdLeft"><textarea id="content" name="content" class="editor" style="width: 100%;">${news.content}</textarea></td>
			</tr>
		</table>
		<table width="98%">
			<tr bgcolor="#EEF4EA">
				<td height="36" colspan="10">
					<input type="button" value="确定" class="button" id="save" />
					<input type="button" value="返回" class="button" onclick="location.href='<%=basePath%>admin/news/list.shtml'" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
